package system

import (
	"github.com/gin-gonic/gin"
	"ruoyi-go/app/admin/api/system"
	"ruoyi-go/utils/perms"
)

func InitUser(e *gin.RouterGroup) {
	auth := e.Group("system")
	{
		auth.GET("/user/list", perms.AutoGenCheck, system.ListUser)
		auth.POST("/user/export", perms.AutoGenCheck, system.ExportExport)
		auth.POST("/user/importData", perms.AutoGenCheck, system.ImportUserData)
		auth.POST("/user/importTemplate", system.ImportTemplate)
		auth.GET("/user/:userId", perms.Check("system:user:query"), system.GetUserInfo)
		auth.GET("/user/", perms.Check("system:user:query"), system.GetUserInfo)
		auth.POST("/user", perms.Check("system:user:add"), system.SaveUser)
		auth.PUT("/user", perms.Check("system:user:edit"), system.UploadUser)
		// 更新用户信息 验证防重复提交和限流中间件
		//auth
		//.Use(utils.RepeatSubmitMiddleware(500))
		//.Use(utils.RateLimiterMiddleware(60, 20, utils.DEFAULT))
		//.PUT("/sysuser", system.UploadUser)
		auth.DELETE("/user/:userIds", perms.Check("system:user:del"), system.DeleteUserById)
		auth.PUT("/user/resetPwd", perms.Check("system:user:resetPwd"), system.ResetPwd)
		auth.PUT("/user/changeStatus", perms.Check("system:user:edit"), system.ChangeUserStatus)
		auth.GET("/user/authRole/:userId", perms.Check("system:user:edit"), system.GetAuthUserRole)
		auth.PUT("/user/authRole", perms.Check("system:user:edit"), system.PutAuthUser)
		auth.GET("/user/deptTree", perms.Check("system:user:edit"), system.GetUserDeptTree)
	}
}
